﻿Imports System.Runtime.Serialization.Formatters.Binary

Public Class Form_userpass
    sub New()

        ' 此调用是设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。

    End Sub
    sub New(ByRef usersup As list(Of UserInfo), ByRef lstuser As UserInfo)

        ' 此调用是设计器所必需的。
        InitializeComponent()

        ' 在 InitializeComponent() 调用之后添加任何初始化。

        users=usersup
        lastuser=lstuser

    End Sub


    Private Property users As new list(Of UserInfo)

    Private Property lastuser As UserInfo
    Private Sub Form_userpass_Load(sender As Object, e As EventArgs) Handles Me.Load

        BtnOk.DialogResult = DialogResult.OK
        BtnCancel.DialogResult = DialogResult.Cancel
        if users IsNot nothing Then
            For Each user in users
                CbxUsername.Items.Add(user.LoginID)
            Next 
            CbxUsername.SelectedIndex=users.FindIndex(Function(u) u.LoginID=lastuser.LoginID)
        End If

 


    End Sub



    Private Sub CbxUsername_SelectedValueChanged(sender As Object, e As EventArgs) Handles CbxUsername.SelectedValueChanged


        For i As Integer = 0 To users.Count - 1
            If CbxUsername.Text <> "" Then
                    If users.exists(Function(x) x.LoginID =CbxUsername.Text) AndAlso users.find(Function(x) x.LoginID = CbxUsername.Text).Pwd <> "" Then
                        Dim aa = users.find(Function(x) x.LoginID = CbxUsername.Text)
                        TbxPassword.Text = aa.Pwd
                        TbxProLimit.Text= aa.LtmPro
                    Else
                        TbxPassword.Text = ""
                    End If

            End If

        Next
       


    End Sub


End Class